package chapter03

import org.apache.spark.{SparkConf, SparkContext}

object Test05_Map {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local[*]").setAppName("map")
    val sc = new SparkContext(conf)
    //创建一个rdd
    val value = sc.makeRDD(List(1, 2, 3, 4, 5))
    //做map算子 都会生成新的rdd
    val value1 = value.map(e => {
      e + 1
    })
    println(value1.collect().mkString("Array(", ", ", ")"))
    //读文件使用map 将单词切分开
    val value2 = sc.textFile("input/word.txt")
    val value3 = value2.map(e => e.split(" ").toList)
    println(value3.collect().mkString("Array(", ", ", ")"))
  }
}
